package com.neusoft.newelm.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.newelm.bean.Role;
import com.neusoft.newelm.common.ElmException;
import com.neusoft.newelm.common.Pager;
import com.neusoft.newelm.mapper.RoleMapper;

/**
 * 
 * @author chens
 *
 */
@Service(value = "RoleServiceImpl4Cglib")
@Transactional(rollbackFor = ElmException.class)
public class RoleServiceImpl4Cglib {

	@Autowired
	private RoleMapper roleMapper;

	public boolean add(Role object) {
		boolean ret = false;
		try {
			ret = roleMapper.add(object);
		} catch (Exception e) {
			throw new ElmException("新增异常", e);
		}
		return ret;
	}

	public boolean edit(Role object) {

		boolean ret = false;
		try {
			ret = roleMapper.edit(object);
		} catch (Exception e) {
			throw new ElmException("修改异常", e);
		}
		return ret;
	}

	public boolean deleteById(Integer id) {

		boolean ret = false;
		try {
			ret = roleMapper.deleteById(id);
		} catch (Exception e) {
			throw new ElmException("删除异常", e);
		}
		return ret;
	}

	public Role findById(Integer id) {
		Role ret = null;

		try {
			ret = roleMapper.findById(id);
		} catch (Exception e) {
			throw new ElmException("查询异常", e);
		}
		return ret;
	}

	public int findRoleotal(Pager<Role> pager) {

		int ret = 0;

		try {
			ret = roleMapper.findTotal(pager);
		} catch (Exception e) {
			throw new ElmException("查询异常", e);
		}
		return ret;
	}

	public List<Role> findByPager(Pager<Role> pager) {

		List<Role> ret = new ArrayList<Role>();

		try {
			ret = roleMapper.findByPager(pager);
		} catch (Exception e) {
			throw new ElmException("查询异常", e);
		}
		return ret;
	}

	public boolean deleteByIds(List<Integer> ids) {

		boolean ret = false;
		try {
			ret = roleMapper.deleteByIds(ids);
		} catch (Exception e) {
			throw new ElmException("删除异常", e);
		}
		return ret;
	}

}
